package com.lmx.repoDomain.repository;

import java.util.Map;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lmx.common.util.CommonUtil;
import com.lmx.persistence.service.DrugFormTypeService;
import com.lmx.repoDomain.tmodel.Drug;
import com.lmx.repoDomain.tmodel.DrugFormType;

import io.katharsis.queryParams.QueryParams;
import io.katharsis.repository.annotations.JsonApiFindAll;
import io.katharsis.repository.annotations.JsonApiResourceRepository;

@JsonApiResourceRepository(DrugFormType.class)
@Component
public class DrugFormTypeRespository  extends BaseRepository<DrugFormType>{
	@Autowired
	private DrugFormTypeService srv;
	@PostConstruct
    public void init() {
        dslJpaService.setEntityClass(DrugFormType.class); 
    }
    @Override
    @JsonApiFindAll
    public Iterable<DrugFormType> findAll(QueryParams requestParams) {
    	Map<String, String> keyMap = CommonUtil.getKeyMapByFilter(requestParams);
    	Long parentId=keyMap.containsKey("parentId")?Long.valueOf(keyMap.get("parentId")):null;
        return this.srv.findAll(parentId);
	}
	  
}
